<template>
    <div class="area-content-pro">
        <div id="main_left_B"></div>
    </div>
</template>
<script>
import * as echarts from 'echarts';
export default {
    props: ["data"],
    data() {
        return {
        }
    },
    watch: {
        data: {
            handler(newVal, oldVal) {
                console.log(newVal, oldVal, "11111111");
                //新旧值不同
                setTimeout(() => {
                    this.area()
                }, 1000);
            },
            deep: true,
            immediate: true
        }
    },
    mounted() {
        // this.area()
    },
    methods: {
        area() {
            var chartDom = document.getElementById('main_left_B');
            console.log(chartDom);
            var myChart = echarts.init(chartDom);
            var option;
            option = {
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow',
                        label: {
                            backgroundColor: '#6a7985'
                        }
                    }
                },
                legend: {
                    itemHeight: '9',
                    textStyle: {
                        color: "#fff"
                    },
                    top: '3%',
                    // icon: 'circle',
                    right: '3%',
                    data: ['轻烃', '液化气']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: [
                    {
                        type: 'category',
                        boundaryGap: false,
                        data: this.data.time,
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "rgba(91, 124, 144, 1)",
                            }

                        },
                        axisTick: {
                            show: false,
                        },

                        axisLabel: {
                            color: "#fff"
                        },

                        splitLine: {
                            show: false
                        },
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        axisLine: {
                            show: true,
                            lineStyle: {
                                color: "rgba(91, 124, 144, 1)",
                            }

                        },
                        axisTick: {
                            show: false,
                        },

                        axisLabel: {
                            color: "#fff"
                        },

                        splitLine: {
                            show: false
                        },

                    }
                ],
                series: [
                    {
                        name: '轻烃',
                        type: 'line',
                        stack: 'Total',
                        itemStyle: {
                            normal: {
                                color: 'rgba(255, 224, 76, 1)'
                            }
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: this.data.lanzhouLiquefiedgas
                    },
                    {
                        name: '液化气',
                        type: 'line',
                        stack: 'Total',
                        itemStyle: {
                            normal: {
                                color: 'rgba(60, 184, 243, 1)'
                            }
                        },
                        emphasis: {
                            focus: 'series'
                        },
                        data: this.data.lanzhouLighthydrocarbon
                    }
                ]
            };
            option && myChart.setOption(option);
        }
    }
}
</script>
<style lang="scss" scoped>
.area-content-pro {

    #main_left_B {
        width: 363px;
        height: 265px;
    }
}
</style>